﻿using System;
using System.Diagnostics;
using System.Runtime.Serialization;

namespace CSC.Google
{
    /// <summary>
    /// Argument for the format string.
    /// </summary>
    [Serializable]
    public class Args
    {
        #region Private Variables
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private string type = null;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private string value = null;
        #endregion

        /// <summary>
        /// Type of argument. One of Url, String_Literal, Int_Literal, Bytes, or Duration.
        /// </summary>
        public ArgType Type
        {
            get
            {
                string[] parts = type.ToLower().Split('_');
                string temp = parts[0][0].ToString().ToUpper() + parts[0].Substring(1);
                if (parts.Length > 1) temp += "_" + parts[1][0].ToString().ToUpper() + parts[1].Substring(1);
                return (ArgType)Enum.Parse(typeof(ArgType), temp);
            }
        }

        /// <summary>
        /// Argument value, as a localized string.
        /// </summary>
        public string Value { get { return value; } }
    }
}
